package com.xinghen.ace.common.model;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author xinghen
 * @ClassName: IndexObject
 * @Package: com.xinghen.ace.common.model
 * @Description 索引对象
 * @create 2018/5/4 14:53
 */
@Data
@NoArgsConstructor
public class IndexObject implements Comparable<IndexObject>, Serializable {

    private Long id;

    private String title;

    private String keywords;

    private String description;

    private String postDate;

    private String url;

    /**
     * 相似度
     */
    private float score;

    public IndexObject(Long id, String keywords, String description, String postDate, float score) {
        this.id = id;
        this.keywords = keywords;
        this.score = score;
        this.description = description;
        this.postDate = postDate;
    }

    @Override
    public int compareTo(IndexObject o) {
        if (this.score < o.getScore()) {
            return 1;
        } else if (this.score > o.getScore()) {
            return -1;
        }
        return 0;
    }


}
